<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>input-focus-blur-change</title>
</head>
<body>

<input type="text"><br>
<input type="text"><br>
<input type="text" value="请输入用户名" onfocus="if(this.value == '请输入用户名'){this.value = ''}"
onblur="if(this.value == ''){this.value = '请输入用户名'}"><br>


<script>
    var input = document.getElementsByTagName("input")[0];
    var change = document.getElementsByTagName("input")[1];
    input.oninput = function () {
        console.log(this.value);
    };
    change.onchange = function () {
        console.log(this.value);
    }
</script>

</body>
</html>
